<?php
namespace app\admin\validate;

use think\Validate;

class Release extends Validate
{
    protected $rule = [
        'title'       => 'require|length:2,100',
        'content'     => 'require',
        'category_id' => 'require|number',
        'status'      => 'require|in:0,1,2',
        'reason'      => 'requireIf:status,2|length:2,255'
    ];

    protected $message = [
        'title.require'       => '标题不能为空',
        'title.length'        => '标题长度必须在2-100个字符之间',
        'content.require'     => '内容不能为空',
        'category_id.require' => '分类不能为空',
        'category_id.number'  => '分类ID必须是数字',
        'status.require'      => '状态不能为空',
        'status.in'           => '状态值不正确',
        'reason.requireIf'    => '拒绝时必须填写原因',
        'reason.length'       => '拒绝原因长度必须在2-255个字符之间'
    ];

    protected $scene = [
        'submit' => ['title', 'content', 'category_id'],
        'audit'  => ['status', 'reason']
    ];
} 